/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 26727
 * Date: 2024-04-15
 * Time: 12:07
 */
//300.最长递增子序列
class Solution1 {
    public int lengthOfLIS(int[] nums) {
        int n = nums.length;
        //1.创建dp表 dp[i]以i结尾的所有子序列中最长递增子序列长度
        int[] dp = new int[n];
        //2.初始化
        for(int i = 0; i < n; i++) {
            dp[i] = 1;
        }
        int ret = 1;
        //3.状态转移
        //4.填表顺序
        for(int i = 1; i < n; i++) {
            for(int j = i-1; j >= 0; j--) {
                if(nums[j] < nums[i]) {
                    dp[i] = Math.max(dp[j]+1,dp[i]);
                }
            }
            ret = Math.max(dp[i],ret);
        }
        //5.返回值
        return ret;
    }
}
